<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>Series | Python 数据分析学习目录</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../数据分析库的初步认识/DataFrame创建.html" />
    
    
    <link rel="prev" href="../数据分析库的初步认识/Pandas创建.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="3.2"
        data-chapter-title="Series"
        data-filepath="数据分析库的初步认识/Series创建.md"
        data-basepath=".."
        data-revision="Wed Oct 24 2018 21:30:49 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        数据分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="Python数据分析序言/内容序言.html">
            
                
                    <a href="../Python数据分析序言/内容序言.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        Python数据分析内容
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="python数据分析环境和工具/Python数据分析相关.html">
            
                
                    <a href="../python数据分析环境和工具/Python数据分析相关.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        python数据分析环境和工具
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="python数据分析环境和工具/1Python数据课程软件和环境安装.html">
            
                
                    <a href="../python数据分析环境和工具/1Python数据课程软件和环境安装.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        Python数据课程 软件和环境安装
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="python数据分析环境和工具/2python发行版.html">
            
                
                    <a href="../python数据分析环境和工具/2python发行版.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        python发行版
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="python数据分析环境和工具/5交互式编辑器-JupyterNotebook.html">
            
                
                    <a href="../python数据分析环境和工具/5交互式编辑器-JupyterNotebook.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        交互式编辑器-JupyterNotebook
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="python数据分析环境和工具/5.1Jupyter-notebook拓展应用.html">
            
                
                    <a href="../python数据分析环境和工具/5.1Jupyter-notebook拓展应用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.1.</b>
                        
                        Jupyter-notebook拓展应用
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="python数据分析环境和工具/包和环境管理器：conda.html">
            
                
                    <a href="../python数据分析环境和工具/包和环境管理器：conda.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        包和环境管理器：conda
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="python数据分析环境和工具/pip和Virtualenv.html">
            
                
                    <a href="../python数据分析环境和工具/pip和Virtualenv.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.1.</b>
                        
                        pip和Virtualenv
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="python数据分析环境和工具/3Markdown.html">
            
                
                    <a href="../python数据分析环境和工具/3Markdown.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        标记语言：Markdown
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="python数据分析环境和工具/4Markdown语法.html">
            
                
                    <a href="../python数据分析环境和工具/4Markdown语法.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.1.</b>
                        
                        Markdown语法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5.2" data-path="python数据分析环境和工具/6Gitbook文档.html">
            
                
                    <a href="../python数据分析环境和工具/6Gitbook文档.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.2.</b>
                        
                        文档管理工具-Gitbook
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="数据分析库的初步认识/index.html">
            
                
                    <a href="../数据分析库的初步认识/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        数据分析库-Pandas
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="数据分析库的初步认识/Pandas创建.html">
            
                
                    <a href="../数据分析库的初步认识/Pandas创建.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        pandas
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="3.2" data-path="数据分析库的初步认识/Series创建.html">
            
                
                    <a href="../数据分析库的初步认识/Series创建.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        Series
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="数据分析库的初步认识/DataFrame创建.html">
            
                
                    <a href="../数据分析库的初步认识/DataFrame创建.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        DataFrame对象-创建
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" >
            
            <span><b>4.</b> 数据分析库的操作</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="数据分析库的操作/1DataFrame查询1-整体.html">
            
                
                    <a href="../数据分析库的操作/1DataFrame查询1-整体.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        DataFrame查询1-整体
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="数据分析库的操作/2DataFrame查询2-专用查询.html">
            
                
                    <a href="../数据分析库的操作/2DataFrame查询2-专用查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        DataFrame查询2-专用查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="数据分析库的操作/3DataFrame查询3-专有查询：过滤查询.html">
            
                
                    <a href="../数据分析库的操作/3DataFrame查询3-专有查询：过滤查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        DataFrame查询3-专有查询：过滤查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="数据分析库的操作/4Pandas对象的数据操作：增删改查.html">
            
                
                    <a href="../数据分析库的操作/4Pandas对象的数据操作：增删改查.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        Pandas对象的数据操作：增删改查
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="数据分析库的操作/5Pandas数据操作：其他操作.html">
            
                
                    <a href="../数据分析库的操作/5Pandas数据操作：其他操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.1.</b>
                        
                        Pandas数据操作：其他操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="数据分析库的操作/6Pandas数据存取.html">
            
                
                    <a href="../数据分析库的操作/6Pandas数据存取.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.2.</b>
                        
                        Pandas数据存取
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.3" data-path="数据分析库的操作/7Pandas数据运算.html">
            
                
                    <a href="../数据分析库的操作/7Pandas数据运算.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.3.</b>
                        
                        Pandas数据运算
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.3.1" data-path="数据分析库的操作/7.1Pandas数据运算拓展.html">
            
                
                    <a href="../数据分析库的操作/7.1Pandas数据运算拓展.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.3.1.</b>
                        
                        Pandas数据运算-拓展
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.4.4" data-path="数据分析库的操作/8Pandas分组聚合1.html">
            
                
                    <a href="../数据分析库的操作/8Pandas分组聚合1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.4.</b>
                        
                        Pandas分组聚合1
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.5" data-path="数据分析库的操作/9Pandas分组聚合2.html">
            
                
                    <a href="../数据分析库的操作/9Pandas分组聚合2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.5.</b>
                        
                        Pandas分组聚合2
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.6" data-path="数据分析库的操作/10Pandas数据规整-清理.html">
            
                
                    <a href="../数据分析库的操作/10Pandas数据规整-清理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.6.</b>
                        
                        Pandas数据规整-清理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.7" data-path="数据分析库的操作/11Pandas数据规整-转换.html">
            
                
                    <a href="../数据分析库的操作/11Pandas数据规整-转换.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.7.</b>
                        
                        Pandas数据规整-转换
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.7.1" data-path="数据分析库的操作/14Pandas数据规整-转换-离散化和面元划分.html">
            
                
                    <a href="../数据分析库的操作/14Pandas数据规整-转换-离散化和面元划分.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.7.1.</b>
                        
                        离散化和面元划分
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.4.8" data-path="数据分析库的操作/16Pandas数据规整-合并.html">
            
                
                    <a href="../数据分析库的操作/16Pandas数据规整-合并.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.8.</b>
                        
                        Pandas数据规整-合并
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="数据分析库的操作/13Pandas数据规整-重塑和轴向旋转.html">
            
                
                    <a href="../数据分析库的操作/13Pandas数据规整-重塑和轴向旋转.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        Pandas数据规整-重塑和轴向旋转
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.5.1" data-path="数据分析库的操作/13.1透视表和交叉表.html">
            
                
                    <a href="../数据分析库的操作/13.1透视表和交叉表.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.1.</b>
                        
                        透视表和交叉表
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="Python可视化/绘图库-Matplotlib.html">
            
                
                    <a href="../Python可视化/绘图库-Matplotlib.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        Python可视化
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="Python可视化/绘图库-Matplotlib/Matplotlib常见图表.html">
            
                
                    <a href="../Python可视化/绘图库-Matplotlib/Matplotlib常见图表.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        基础：Matplotlib常见图表
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1.1" data-path="Python可视化/绘图库-Matplotlib/Matplotlib常见设置和操作.html">
            
                
                    <a href="../Python可视化/绘图库-Matplotlib/Matplotlib常见设置和操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.1.</b>
                        
                        Matplotlib常见设置和操作
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="Python可视化/绘图库-Matplotlib/1Matplotlib-绘图区域.html">
            
                
                    <a href="../Python可视化/绘图库-Matplotlib/1Matplotlib-绘图区域.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        提升：绘图区域
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="Python可视化/绘图库-Matplotlib/2Matplotlib-图像组件.html">
            
                
                    <a href="../Python可视化/绘图库-Matplotlib/2Matplotlib-图像组件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        提升：绘图组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="Python可视化/绘图库-Matplotlib/3Matplotlib-高级绘图.html">
            
                
                    <a href="../Python可视化/绘图库-Matplotlib/3Matplotlib-高级绘图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        拓展：高级绘图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="Python可视化/绘图库-Matplotlib/4数学计算展示图像.html">
            
                
                    <a href="../Python可视化/绘图库-Matplotlib/4数学计算展示图像.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        拓展：数学计算展示图像
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="Python可视化/绘图库-Matplotlib/5注意事项.html">
            
                
                    <a href="../Python可视化/绘图库-Matplotlib/5注意事项.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        拓展：注意事项
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="Python可视化/绘图库-Matplotlib/6pylab.html">
            
                
                    <a href="../Python可视化/绘图库-Matplotlib/6pylab.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        拓展：pylab
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="数据分析必备知识点/数据分析必备知识点汇集.html">
            
                
                    <a href="../数据分析必备知识点/数据分析必备知识点汇集.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        数据分析必备知识点
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7" data-path="数据分析必备知识点/数据分析流程.html">
            
                
                    <a href="../数据分析必备知识点/数据分析流程.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        数据分析流程
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >Python 数据分析学习目录</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h2 id="series-">Series </h2>
<hr>
<p>Pandas &#x7684;&#x4E00;&#x7EF4;&#x6570;&#x636E;&#x7ED3;&#x6784;</p>
<p><img src="images/&#x4E00;&#x7EF4;Series.png" alt="&#x4E00;&#x7EF4;&#x6570;&#x636E;&#x7ED3;&#x6784;"></p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
</code></pre>
<h1 id="&#x521B;&#x5EFA;">&#x521B;&#x5EFA;</h1>
<h2 id="&#x5217;&#x8868;&#x521B;&#x5EFA;-series">&#x5217;&#x8868;&#x521B;&#x5EFA; Series</h2>
<pre><code class="lang-python"><span class="hljs-comment">#&#x9ED8;&#x8BA4;&#x7D22;&#x5F15;</span>
a = pd.Series([<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">6</span>])
a
</code></pre>
<pre><code>    0    3
    1    4
    2    5
    3    6
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x81EA;&#x5B9A;&#x4E49;&#x7D22;&#x5F15;</span>
b = pd.Series([<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">6</span>],index = [<span class="hljs-string">&apos;a&apos;</span>,<span class="hljs-string">&apos;b&apos;</span>,<span class="hljs-string">&apos;c&apos;</span>,<span class="hljs-string">&apos;d&apos;</span>])
b
</code></pre>
<pre><code>    a    3
    b    4
    c    5
    d    6
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment"># &#x503C;&#x53EF;&#x4EE5;&#x5B58;&#x50A8;&#x4E0D;&#x540C;&#x7C7B;&#x578B;</span>

c = pd.Series([<span class="hljs-string">&apos;&#x5C0F;&#x660E;&apos;</span>,<span class="hljs-number">18</span>,<span class="hljs-number">177</span>,<span class="hljs-keyword">True</span>],index = [<span class="hljs-string">&apos;name&apos;</span>,<span class="hljs-string">&apos;age&apos;</span>,<span class="hljs-string">&apos;height&apos;</span>,<span class="hljs-string">&apos;gender&apos;</span>])
c
</code></pre>
<pre><code>    name        &#x5C0F;&#x660E;
    age         18
    height     177
    gender    True
    dtype: object
</code></pre><h2 id="&#x5B57;&#x5178;&#x521B;&#x5EFA;series">&#x5B57;&#x5178;&#x521B;&#x5EFA;Series</h2>
<pre><code class="lang-python">d = pd.Series({<span class="hljs-string">&apos;name&apos;</span>:<span class="hljs-string">&apos;&#x5C0F;&#x660E;&apos;</span>,<span class="hljs-string">&apos;age&apos;</span>:<span class="hljs-number">18</span>,<span class="hljs-string">&apos;height&apos;</span>:<span class="hljs-number">177</span>,<span class="hljs-string">&apos;gender&apos;</span>:<span class="hljs-keyword">True</span>})
d
</code></pre>
<pre><code>    name        &#x5C0F;&#x660E;
    age         18
    height     177
    gender    True
    dtype: object
</code></pre><pre><code class="lang-python"><span class="hljs-comment"># &#x8986;&#x76D6;&#x81EA;&#x5E26;&#x7684;&#x7D22;&#x5F15;</span>

d = pd.Series(
    {<span class="hljs-string">&apos;name&apos;</span>:<span class="hljs-string">&apos;&#x5C0F;&#x660E;&apos;</span>,<span class="hljs-string">&apos;age&apos;</span>:<span class="hljs-number">18</span>,<span class="hljs-string">&apos;height&apos;</span>:<span class="hljs-number">177</span>,<span class="hljs-string">&apos;gender&apos;</span>:<span class="hljs-keyword">True</span>},
    index = [<span class="hljs-string">&apos;name&apos;</span>,<span class="hljs-string">&apos;age&apos;</span>,<span class="hljs-string">&apos;height&apos;</span>,<span class="hljs-string">&apos;address&apos;</span>]
)

d
</code></pre>
<pre><code>    name        &#x5C0F;&#x660E;
    age         18
    height     177
    address    NaN
    dtype: object
</code></pre><h1 id="&#x5176;&#x4ED6;&#x65B9;&#x5F0F;&#x521B;&#x5EFA;serise">&#x5176;&#x4ED6;&#x65B9;&#x5F0F;&#x521B;&#x5EFA;Serise</h1>
<pre><code class="lang-python"><span class="hljs-comment"># &#x6807;&#x91CF;&#x521B;&#x5EFA;</span>

pd.Series(<span class="hljs-number">10</span>)
pd.Series(<span class="hljs-number">10</span>,index=range(<span class="hljs-number">10</span>))
</code></pre>
<pre><code>    0    10
    1    10
    2    10
    3    10
    4    10
    5    10
    6    10
    7    10
    8    10
    9    10
    dtype: int64
</code></pre><pre><code class="lang-python">range(<span class="hljs-number">10</span>)   <span class="hljs-comment">#&#x8FED;&#x4EE3;&#x5668;</span>
</code></pre>
<pre><code>    range(0, 10)
</code></pre><pre><code class="lang-python">list(range(<span class="hljs-number">10</span>))
</code></pre>
<pre><code>    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
</code></pre><pre><code class="lang-python">pd.Series(range(<span class="hljs-number">10</span>))
</code></pre>
<pre><code>    0    0
    1    1
    2    2
    3    3
    4    4
    5    5
    6    6
    7    7
    8    8
    9    9
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment"># numpy &#x7684;arange &#x5E8F;&#x5217;&#x521B;&#x5EFA;</span>
np.arange(<span class="hljs-number">10</span>)
np.arange(<span class="hljs-number">5</span>,<span class="hljs-number">9</span>)
np.arange(<span class="hljs-number">9</span>,<span class="hljs-number">4</span>,-<span class="hljs-number">1</span>)
</code></pre>
<pre><code>    array([9, 8, 7, 6, 5])
</code></pre><pre><code class="lang-python">pd.Series(np.arange(<span class="hljs-number">5</span>), index=np.arange(<span class="hljs-number">9</span>, <span class="hljs-number">4</span>, -<span class="hljs-number">1</span>))
</code></pre>
<pre><code>    9    0
    8    1
    7    2
    6    3
    5    4
    dtype: int32
</code></pre><hr>
<h2 id="&#x67E5;&#x8BE2;">&#x67E5;&#x8BE2;</h2>
<hr>
<pre><code class="lang-python">class1 = pd.Series([<span class="hljs-number">100</span>, <span class="hljs-number">25</span>, <span class="hljs-number">59</span>, <span class="hljs-number">90</span>, <span class="hljs-number">61</span>], index=[<span class="hljs-string">&apos;ming&apos;</span>, <span class="hljs-string">&apos;hua&apos;</span>, <span class="hljs-string">&apos;hong&apos;</span>, <span class="hljs-string">&apos;huang&apos;</span>, <span class="hljs-string">&apos;bai&apos;</span>])

class1
</code></pre>
<pre><code>    ming     100
    hua       25
    hong      59
    huang     90
    bai       61
    dtype: int64
</code></pre><h1 id="&#x67E5;&#x8BE2;-&#x952E;index&#x548C;-&#x503C;&#xFF08;values&#xFF09;">&#x67E5;&#x8BE2; &#x952E;(index)&#x548C; &#x503C;&#xFF08;values&#xFF09;</h1>
<pre><code class="lang-python"><span class="hljs-comment">#&#x503C; &#x6570;&#x7EC4;</span>
class1.values
</code></pre>
<pre><code>    array([100,  25,  59,  90,  61], dtype=int64)
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x952E;</span>
class1.index
</code></pre>
<pre><code>    Index([&apos;ming&apos;, &apos;hua&apos;, &apos;hong&apos;, &apos;huang&apos;, &apos;bai&apos;], dtype=&apos;object&apos;)
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x952E;&#x7684;&#x672C;&#x8D28;&#x4E5F;&#x662F;&#x6570;&#x7EC4;</span>
class1.index.values
</code></pre>
<pre><code>    array([&apos;ming&apos;, &apos;hua&apos;, &apos;hong&apos;, &apos;huang&apos;, &apos;bai&apos;], dtype=object)
</code></pre><pre><code class="lang-python">class1.values[<span class="hljs-number">2</span>]
</code></pre>
<pre><code>    59
</code></pre><h1 id="&#x7D22;&#x5F15;&#x67E5;&#x8BE2;">&#x7D22;&#x5F15;&#x67E5;&#x8BE2;</h1>
<pre><code class="lang-python">class1
</code></pre>
<pre><code>    ming     100
    hua       25
    hong      59
    huang     90
    bai       61
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x67E5;&#x8BE2;&#x5355;&#x503C;</span>
<span class="hljs-comment">#Series &#x6709;&#x4E24;&#x5957;&#x7D22;&#x5F15;&#xFF0C;&#x9ED8;&#x8BA4;&#x7D22;&#x5F15;&#xFF0C;&#x81EA;&#x5B9A;&#x4E49;&#x7D22;&#x5F15;&#x3002;</span>
class1[<span class="hljs-string">&apos;hong&apos;</span>]
class1[<span class="hljs-number">2</span>]
</code></pre>
<pre><code>    59
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x67E5;&#x8BE2;&#x591A;&#x503C;</span>
class1[[<span class="hljs-number">1</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>]]
</code></pre>
<pre><code>    hua      25
    huang    90
    bai      61
    dtype: int64
</code></pre><pre><code class="lang-python">class1[[<span class="hljs-string">&apos;hua&apos;</span>,<span class="hljs-string">&apos;huang&apos;</span>,<span class="hljs-string">&apos;bai&apos;</span>]]
</code></pre>
<pre><code>    hua      25
    huang    90
    bai      61
    dtype: int64
</code></pre><h1 id="class11-hua-huang-&#x9519;&#x8BEF;&#xFF0C;&#x4E24;&#x5957;&#x7D22;&#x5F15;&#x5E76;&#x5B58;&#x4F46;&#x4E0D;&#x80FD;&#x6DF7;&#x7528;">class1[[1, &apos;hua&apos;, &apos;huang&apos;]] #&#x9519;&#x8BEF;&#xFF0C;&#x4E24;&#x5957;&#x7D22;&#x5F15;&#x5E76;&#x5B58;,&#x4F46;&#x4E0D;&#x80FD;&#x6DF7;&#x7528;</h1>
<h1 id="&#x5207;&#x7247;&#x67E5;&#x8BE2;">&#x5207;&#x7247;&#x67E5;&#x8BE2;</h1>
<pre><code class="lang-python">class1
</code></pre>
<pre><code>    ming     100
    hua       25
    hong      59
    huang     90
    bai       61
    dtype: int64
</code></pre><pre><code class="lang-python">class1[:<span class="hljs-number">3</span>] <span class="hljs-comment">#&#x9ED8;&#x8BA4;&#x7D22;&#x5F15;&#x4E0D;&#x5305;&#x542B;&#x7ED3;&#x675F;&#x503C;</span>
</code></pre>
<pre><code>    ming    100
    hua      25
    hong     59
    dtype: int64
</code></pre><pre><code class="lang-python">class1.index
</code></pre>
<pre><code>    Index([&apos;ming&apos;, &apos;hua&apos;, &apos;hong&apos;, &apos;huang&apos;, &apos;bai&apos;], dtype=&apos;object&apos;)
</code></pre><pre><code class="lang-python">class1[<span class="hljs-number">2</span>:]
</code></pre>
<pre><code>    hong     59
    huang    90
    bai      61
    dtype: int64
</code></pre><pre><code class="lang-python">class1[:<span class="hljs-string">&apos;huang&apos;</span>] <span class="hljs-comment">#&#x81EA;&#x5B9A;&#x4E49;&#x7D22;&#x5F15;&#xFF0C;&#x5305;&#x542B;&#x7ED3;&#x675F;&#x503C;</span>
</code></pre>
<pre><code>    ming     100
    hua       25
    hong      59
    huang     90
    dtype: int64
</code></pre><pre><code class="lang-python">class1[<span class="hljs-string">&apos;hong&apos;</span>:]
</code></pre>
<pre><code>    hong     59
    huang    90
    bai      61
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x6B65;&#x957F;</span>
class1[::<span class="hljs-number">2</span>]
</code></pre>
<pre><code>    ming    100
    hong     59
    bai      61
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x5012;&#x6392;</span>
class1[::-<span class="hljs-number">1</span>]
</code></pre>
<pre><code>    bai       61
    huang     90
    hong      59
    hua       25
    ming     100
    dtype: int64
</code></pre><h3 id="&#x5411;&#x91CF;&#x5316;&#x8FD0;&#x7B97;">&#x5411;&#x91CF;&#x5316;&#x8FD0;&#x7B97;</h3>
<h4 id="&#x5E76;&#x884C;&#x7F16;&#x7A0B;">&#x5E76;&#x884C;&#x7F16;&#x7A0B;</h4>
<pre><code class="lang-python">class1
</code></pre>
<pre><code>    ming     100
    hua       25
    hong      59
    huang     90
    bai       61
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x539F;&#x751F;python &#xFF0C;&#x904D;&#x5386;&#x5E8F;&#x5217;&#x8FD0;&#x7B97;</span>
<span class="hljs-comment">#&#x901F;&#x5EA6;&#x6162;&#xFF0C;&#x6548;&#x7387;&#x4F4E;</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> class1:
    print(i)
    print(i+<span class="hljs-number">10</span>)
</code></pre>
<pre><code>    100
    110
    25
    35
    59
    69
    90
    100
    61
    71
</code></pre><pre><code class="lang-python"><span class="hljs-comment"># &#x5411;&#x91CF;&#x5316;&#x8FD0;&#x7B97;</span>
class1 + <span class="hljs-number">10</span>
</code></pre>
<pre><code>    ming     110
    hua       35
    hong      69
    huang    100
    bai       71
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment"># &#x5E03;&#x5C14;&#x8FD0;&#x7B97;</span>
class1 &lt; <span class="hljs-number">60</span>
</code></pre>
<pre><code>    ming     False
    hua       True
    hong      True
    huang    False
    bai      False
    dtype: bool
</code></pre><pre><code class="lang-python"><span class="hljs-comment"># &#x5E94;&#x7528;&#x8FD0;&#x7B97;&#x51FD;&#x6570;</span>
np.median(class1)
</code></pre>
<pre><code>    61.0
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x5E73;&#x5747;&#x503C;</span>
np.mean(class1)
class1.mean()
</code></pre>
<pre><code>    67.0
</code></pre><h3 id="&#x7C7B;&#x4F3C;python&#x5B57;&#x5178;&#x7684;&#x64CD;&#x4F5C;">&#x7C7B;&#x4F3C;Python&#x5B57;&#x5178;&#x7684;&#x64CD;&#x4F5C;</h3>
<ul>
<li>&#x4FDD;&#x7559;&#x5B57;in&#x64CD;&#x4F5C;</li>
<li>&#x4F7F;&#x7528;.get()&#x65B9;&#x6CD5;</li>
</ul>
<pre><code class="lang-python">class1
</code></pre>
<pre><code>    ming     100
    hua       25
    hong      59
    huang     90
    bai       61
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-string">&apos;xiao&apos;</span> <span class="hljs-keyword">in</span> class1 <span class="hljs-comment">#&#x5224;&#x65AD;&#x4E00;&#x4E2A;&#x503C;&#x662F;&#x5426;&#x5B58;&#x5728;&#x4E8E;&#x4E00;&#x4E2A;&#x952E;&#x4E2D;&#xFF0C;</span>
<span class="hljs-string">&apos;hua&apos;</span> <span class="hljs-keyword">in</span> class1
</code></pre>
<pre><code>    True
</code></pre><pre><code class="lang-python">class1.get(<span class="hljs-string">&apos;xiao&apos;</span>,<span class="hljs-number">60</span>) <span class="hljs-comment">#&#x5224;&#x65AD;&#x4E00;&#x4E2A;&#x503C;&#x662F;&#x5426;&#x5B58;&#x5728;&#x4E8E;&#x4E00;&#x4E2A;&#x952E;&#x4E2D;&#xFF0C;&#x5B58;&#x5728;&#x76F4;&#x63A5;&#x8F93;&#x51FA;&#xFF0C;&#x4E0D;&#x5B58;&#x5728;&#x7528;&#x9ED8;&#x8BA4;&#x503C;&#x66FF;&#x6362;</span>
</code></pre>
<pre><code>    60
</code></pre><pre><code class="lang-python">class1.get(<span class="hljs-string">&apos;hua&apos;</span>,<span class="hljs-number">60</span>)
</code></pre>
<pre><code>    25
</code></pre><h2 id="u&#xFF0C;update&#xFF0C;&#x4FEE;&#x6539;">U&#xFF0C;update&#xFF0C;&#x4FEE;&#x6539;</h2>
<h3 id="read&#x67E5;&#x8BE2;&#x9009;&#x4E2D;&#x8D4B;&#x503C;&#x5373;&#x53EF;&#x4FEE;&#x6539;">read&#x67E5;&#x8BE2;&#x9009;&#x4E2D;&#x8D4B;&#x503C;&#x5373;&#x53EF;&#x4FEE;&#x6539;</h3>
<pre><code class="lang-python">class1
</code></pre>
<pre><code>
    ming     100
    hua       25
    hong      59
    huang     90
    bai       61
    dtype: int64
</code></pre><h4 id="&#x4FEE;&#x6539;&#x503C;--&#xFF0C;values">&#x4FEE;&#x6539;&#x503C;  &#xFF0C;values</h4>
<pre><code class="lang-python">class1[<span class="hljs-number">1</span>]
class1[<span class="hljs-number">1</span>] = <span class="hljs-number">58</span>
class1
</code></pre>
<pre><code>    ming     100
    hua       58
    hong      59
    huang     90
    bai       61
    dtype: int64
</code></pre><pre><code class="lang-python">class1[[<span class="hljs-string">&apos;hua&apos;</span>,<span class="hljs-string">&apos;hong&apos;</span>]]
class1[[<span class="hljs-string">&apos;hua&apos;</span>,<span class="hljs-string">&apos;hong&apos;</span>]] = <span class="hljs-number">61</span>,<span class="hljs-number">62</span>
class1
</code></pre>
<p> ```   ming     100
    hua       61
    hong      62
    huang     90
    bai       61
    dtype: int64</p>
<pre><code>

```python
class1[&apos;hua&apos;,&apos;hong&apos;] = [50,51]
class1[&apos;hua&apos;,&apos;hong&apos;] = 68,88  #&#x5355;&#x5C42;&#x62EC;&#x53F7;&#x4E5F;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4FEE;&#x6539;&#x3002;

class1
</code></pre><pre><code>    ming     100
    hua       68
    hong      88
    huang     90
    bai       61
    dtype: int64
</code></pre><h5 id="&#x4FEE;&#x6539;&#x952E;&#xFF0C;index">&#x4FEE;&#x6539;&#x952E;&#xFF0C;index</h5>
<pre><code class="lang-python">class1
</code></pre>
<pre><code>    ming     100
    hua       68
    hong      88
    huang     90
    bai       61
    dtype: int64
</code></pre><pre><code class="lang-python">class1.index
</code></pre>
<pre><code>    Index([&apos;ming&apos;, &apos;hua&apos;, &apos;hong&apos;, &apos;huang&apos;, &apos;bai&apos;], dtype=&apos;object&apos;)
</code></pre><pre><code class="lang-python">class1.index = [<span class="hljs-string">&apos;xiaoming&apos;</span>,<span class="hljs-string">&apos;xiaohua&apos;</span>,<span class="hljs-string">&apos;xiaohong&apos;</span>,<span class="hljs-string">&apos;xiaohuang&apos;</span>,<span class="hljs-string">&apos;xiaobai&apos;</span>]
class1
</code></pre>
<pre><code>    xiaoming     100
    xiaohua       68
    xiaohong      88
    xiaohuang     90
    xiaobai       61
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment"># &#x4FEE;&#x6539;&#x5355;&#x72EC;&#x9009;&#x4E2D;&#x7684;&#x7D22;&#x5F15;&#x503C;</span>
<span class="hljs-comment"># class1.index.values[0] = &apos;aa&apos; #&#x9519;&#x8BEF;&#x7684;&#x4FEE;&#x6539;&#x65B9;&#x6CD5;&#xFF0C;&#x4FEE;&#x6539;&#x540E;&#x7D22;&#x5F15;&#x4E0D;&#x80FD;&#x8C03;&#x7528;</span>
class1
</code></pre>
<pre><code>    xiaoming     100
    xiaohua       68
    xiaohong      88
    xiaohuang     90
    xiaobai       61
    dtype: int64
</code></pre><pre><code class="lang-python"><span class="hljs-comment">#&#x590D;&#x5236;&#x526F;&#x672C;&#x800C;&#x975E;&#x5F15;&#x7528;&#x89C6;&#x56FE;&#xFF0C;&#x7C7B;&#x4F3C;&#x6DF1;&#x62F7;&#x8D1D;</span>
<span class="hljs-comment"># class2 = class1.copy()</span>
<span class="hljs-comment"># class2.index.values[1] = &apos;bbb&apos; #&#x9519;&#x8BEF;&#x7684;&#x4FEE;&#x6539;&#x65B9;&#x6CD5;&#xFF0C;&#x4FEE;&#x6539;&#x540E;&#x7D22;&#x5F15;&#x4E0D;&#x80FD;&#x8C03;&#x7528;</span>
<span class="hljs-comment"># class2</span>
</code></pre>
<pre><code class="lang-python">class1.values[<span class="hljs-number">3</span>] = <span class="hljs-number">99</span>
</code></pre>
<pre><code class="lang-python">class1
</code></pre>
<pre><code>    xiaoming     100
    xiaohua       68
    xiaohong      88
    xiaohuang     99
    xiaobai       61
    dtype: int64
</code></pre><pre><code class="lang-python">class1.index.values[<span class="hljs-number">4</span>]
</code></pre>
<pre><code>
    &apos;xiaobai&apos;
</code></pre><pre><code class="lang-python"><span class="hljs-comment"># class1[&apos;aa&apos;]  #&#x6CA1;&#x6709;&#x66F4;&#x6539;&#x5E95;&#x5C42;&#xFF0C;&#x4F1A;&#x62A5;&#x9519;&#xFF0C;&#x7D22;&#x5F15;&#x4E0D;&#x80FD;&#x8C03;&#x7528;</span>
</code></pre>
<pre><code class="lang-python"><span class="hljs-comment"># &#x6B63;&#x786E;&#x7684;&#x4FEE;&#x6539;&#x7D22;&#x5F15;&#x9009;&#x4E2D;&#x503C;&#x7684;&#x65B9;&#x6CD5;</span>
class3 = class1.rename({<span class="hljs-string">&apos;xiaoming&apos;</span>:<span class="hljs-string">&apos;hui&apos;</span>,<span class="hljs-string">&apos;xiaobai&apos;</span>:<span class="hljs-string">&apos;hei&apos;</span>})   <span class="hljs-comment">#&#x4FEE;&#x6539;&#x4E86;&#x89C6;&#x56FE;</span>
class3
</code></pre>
<pre><code>    hui          100
    xiaohua       68
    xiaohong      88
    xiaohuang     99
    hei           61
    dtype: int64
</code></pre><pre><code class="lang-python">class1  <span class="hljs-comment">#class1 &#x539F; &#x6570;&#x636E;&#x503C;&#x6CA1;&#x6709;&#x4FEE;&#x6539;</span>
</code></pre>
<pre><code>    xiaoming     100
    xiaohua       68
    xiaohong      88
    xiaohuang     99
    xiaobai       61
    dtype: int64
</code></pre><pre><code class="lang-python">class3[<span class="hljs-string">&apos;xiaohua&apos;</span>]
</code></pre>
<pre><code>    68
</code></pre><pre><code class="lang-python">class1
</code></pre>
<pre><code>    xiaoming     100
    xiaohua       68
    xiaohong      88
    xiaohuang     99
    xiaobai       61
    dtype: int64
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../数据分析库的初步认识/Pandas创建.html" class="navigation navigation-prev " aria-label="Previous page: pandas"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../数据分析库的初步认识/DataFrame创建.html" class="navigation navigation-next " aria-label="Next page: DataFrame对象-创建"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
